package com.example.demo.listener.event;

import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.context.ApplicationListener;

/**
 * Created by lisen on 2017/7/4.
 * ApplicationFailedEvent:spring boot启动异常时执行事件
 */
public class MyApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent> {
    @Override
    public void onApplicationEvent(ApplicationFailedEvent event) {
        Throwable throwable = event.getException();
        handleThrowable(throwable);
    }

    private void handleThrowable(Throwable throwable) {
        throwable.printStackTrace();
    }
}
